{include file="include/top"}
<style>
    td,.layui-table th{
        text-align: center;!important;
    }
    .layui-col-md12{
        display: flex;
    }
</style>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">期数管理</a>
            <a>
              <cite>众筹期数</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card" style="width: 100%;">
                <div class="layui-card-body ">
                    <div class="layui-row">
                        <form class="layui-form layui-col-md12 x-so" action="{:url('Raise/RaiseList')}" method="get">
                            <input class="layui-input" placeholder="开始日" name="start" id="start" style="width: 15%;margin: 10px 10px 10px 0px">
                            <input class="layui-input" placeholder="截止日" name="end" id="end" style="width: 15%;margin: 10px 10px 10px 0px">
                            <div style="margin: 10px 10px 10px 0px;width: 120px;">
                                <select name="city" lay-verify="required">
                                    <option value="ra_nper">期数</option>
                                </select>
                            </div>
                            <input type="text" name="key"  placeholder="请输入搜索内容" autocomplete="off" class="layui-input" style="width: 15%;margin: 10px 10px 10px 0px"   >
                            <input class="layui-btn" name="sub" type="submit" value="搜索" style="margin: 10px 10px 10px 0px">
                        </form>
                    </div>
                    <xblock>
                        <button class="layui-btn" onclick="edit()"><i class="layui-icon"></i>发布新一期</button>
                    </xblock>
                    <table class="layui-table layui-form" >
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>众筹期数</th>
                            <th>众筹数量</th>
                            <th>已参与人数</th>
                            <th>开始时间</th>
                            <th>结束时间</th>
                            <th>当前状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="list" id="data"}
                        <tr>
                            <td>{$key+1}</td>
                            <td>第<span style="color: red">{$data.ra_nper}</span>期</td>
                            <td>{$data.ra_num}</td>
                            <td>{$data.ra_part}</td>
                            <td>{$data.ra_atime|date="Y-m-d H:i:s",###}</td>
                            <td>{$data.ra_ltime|date="Y-m-d H:i:s",###}</td>
                            {if $data.ra_state == 1}
                            <td>进行中...</td>
                            {elseif $data.ra_state == 3}
                            <td>爆仓</td>
                            {elseif $data.ra_state == 4}
                            <td>等待分配...</td>
                            {else}
                            <td>已完成</td>
                            {/if}
                            <td style="min-width: 106px;">
                                {if $data.ra_state == 1}
                                <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="sub('{$data.ra_id}')">强制结束</button>
                                {elseif $data.ra_state == 2}
                                已完成
                                {elseif $data.ra_state == 3}
                                爆仓
                                {else}
                                等待分配
                                {/if}
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$page}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
    //添加查看弹框
    function edit(id = '')
    {
        var url = '{:url("Raise/RaiseAdd")}';
        var desc = '发布新一期众筹';
        var arr = ['80%','90%'];
        var loading =  layer.load(0, {shade: false});
        layer.open({
            type: 2,
            title:desc,
            area: arr,
            content: url
        });
        layer.close(loading);
    }

    //通过
    function sub(id) {
        $.ajax({
            type:'post',
            url:'{:url("Raise/RaiseForce")}',
            data:{id:id},
            success: function(data){
                if(data.code>0){
                    layer.msg(data.msg,{icon:1,time:1000});
                    setTimeout(function () {
                        location.reload();
                    }, 1000);
                }else{
                    layer.msg(data.msg,{icon:5,time:1500});
                }
            }
        });
    }
</script>
</html>